% checks if there is a spindles in a given epoch
function [spindles] = isSpindle(original)

filteredSignal = bpfil(original, 12, 15);
len = length(filteredSignal);
counter = 0;
spindles = 0;

for i=1:10:len
    
    %rms10 = rms( filteredSignal( min( len, (i:i+9) )) );
    rms10 = rms( filteredSignal( i : min( len, i+9) ));
    
    if rms10 > 10
        counter = counter + 1; 
        if counter > 5
            spindles = spindles + 1;
            counter = 0;
        end        
    else
        counter = 0;
    end
end
